﻿@model IEnumerable<KopeykaStore.Models.Category>
@helper Truncate(string input, int length)
    {
        if (string.IsNullOrWhiteSpace(input))
        {
            return;
        }
        if (input.Length <= length)
        {
    @input
        }
        else
        {
    @input.Substring(0, length)<text>...</text>
        }
}
@{
    ViewBag.Title = "Categories";
}
<h2>@ViewBag.Title</h2>
<p>
    @Html.ActionLink("Create New", "Create")
</p>
<table>
    <tr>
        <th>
            Name
        </th>
        <th>
            Description
        </th>
        <th>
        </th>
    </tr>
    @foreach (var item in Model)
    {
        <tr>
            <td>
                @Html.DisplayFor(modelItem => item.Name)
            </td>
            <td>
                @Truncate(item.Description, 25)
            </td>
            <td>
                @Html.ActionLink("Edit", "Edit", new { id = item.CategoryId }) |
@*                @Html.ActionLink("Details", "Details", new { id = item.CategoryId }) |
*@                @Html.ActionLink("Delete", "Delete", new { id = item.CategoryId })
            </td>
        </tr>
    }
</table>
